package chunk.control;

import java.awt.Dimension;
import java.awt.Toolkit;

import chunk.model.Hero;
import chunk.view.MainFrame;
import chunk.view.MyPanel;

public class GameManager {

	class GameThread extends Thread {

		MyPanel myPanel = null;

		public GameThread(MyPanel myPanel) {
			this.myPanel = myPanel;
		}

		@Override
		public void run() {

			while (true) {
				if(isOver){
					break;
				}
				myPanel.repaint();
				try {
					Thread.currentThread();
					Thread.sleep(40);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}

	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		GameManager gameManager = new GameManager();
		gameManager.startGame();

	}
	
	private boolean isOver = false;

	public boolean isOver() {
		return isOver;
	}

	public void setOver(boolean isOver) {
		this.isOver = isOver;
	}

	private MainFrame mainFrame = null;

	
	
	public MainFrame getMainFrame() {
		return mainFrame;
	}

	public void setMainFrame(MainFrame mainFrame) {
		this.mainFrame = mainFrame;
	}
	
	private void startGame() {

		mainFrame = new MainFrame(this);
		mainFrame.addBoxs();
		GameThread gameThread = new GameThread(mainFrame.getMyPanel());
		gameThread.start();
		

	}

}
